#include "stdafx.h"
/////////////////////////////////////////////////////////////////////////////
zwl_safe_file::zwl_safe_file(void):object(NULL)
{
}

zwl_safe_file::~zwl_safe_file(void)
{
	if(object)
	{
		safe_file*pfile=(safe_file*)object;
		pfile->Close();
		delete	pfile;
		object = NULL;
	}
}
/////////////////////////////////////////////////////////////////////////////
BOOL zwl_safe_file::IsOpend(void)
{
	if(object)
	{
		return(((safe_file*)object)->IsOpend());
	}
	return(FALSE);
}

BOOL zwl_safe_file::Open(LPCTSTR filename,BOOL blNew)
{
	if(!object)
	{
		safe_file*pfile=new safe_file;
		object = pfile;
	}
	if(object)
	{
		return(((safe_file*)object)->Open(filename,blNew,TRUE));
	}
	return(FALSE);
}

void zwl_safe_file::Close(void)
{
	if(object)
	{
		((safe_file*)object)->Close();
	}
}

BOOL zwl_safe_file::Read(LPVOID buffer,DWORD offset,DWORD size)
{
	return(((safe_file*)object)->ReadFromFile(buffer,offset,size,FALSE));
}

BOOL zwl_safe_file::Write(LPCVOID buffer,DWORD offset,DWORD size)
{
	return(((safe_file*)object)->WriteToFile(buffer,offset,size,FALSE));
}
